package com.zhiwei.fast.fragments

import android.os.Bundle
import android.view.View
import com.blankj.utilcode.util.LogUtils
import com.drake.net.time.Interval
import com.zhiwei.fast.databinding.FragmentProgressRingBinding
import com.zhiwei.fast.fragments.models.ProgressRingFragmentViewModel
import com.zhiwei.most.base.fragment.BaseVmVbFragment
import com.zhiwei.most.ext.nav
import com.zhiwei.most.ext.views.setSwipePanel
import com.zhiwei.most.swipepanel.SwipePanel
import java.util.concurrent.TimeUnit
import kotlin.random.Random

/**
 * Create by zhiweizhu on 2022/2/26
 */
class ProgressRingFragment :
    BaseVmVbFragment<ProgressRingFragmentViewModel, FragmentProgressRingBinding>() {


    override fun initView(savedInstanceState: Bundle?) {
        //倒计时 10秒
        Interval(
            1,
            1,
            TimeUnit.SECONDS,
            10
        )
            .life(viewLifecycleOwner)
            .subscribe {
                LogUtils.d("当前倒计时: $it")
                mViewBind.rrogressRing.setProgress(Random.nextInt(0, 100))
            }.finish {
                mViewBind.rrogressRing.setProgress(Random.nextInt(0, 100))
                LogUtils.d("倒计时完成: $it")
            }.start()

        with(mViewBind){
            swipePanel.setSwipePanel {
                nav().navigateUp()
            }
        }
    }

    override fun createObserver() {
    }

    override fun lazyLoadData() {
    }
}